//
//  SAPAudioViewController.m
//  CarsHome
//
//  Created by dapeng on 15/12/16.
//  Copyright © 2015年 dapeng. All rights reserved.
//

#import "SAPAudioViewController.h"

@interface SAPAudioViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, retain) UITableView *tableView;
@end

@implementation SAPAudioViewController
- (void)dealloc {
    [_tableView release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"我的电台";
    [self tableViews];
}
- (void)tableViews {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_SIZE.width, SCREEN_SIZE.height) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[SAPLIvePlayTableViewCell class] forCellReuseIdentifier:@"SAPLIvePlayTableViewCellIndentifier"];
    [self.tableView registerClass:[SAPAudioTableViewCell class] forCellReuseIdentifier:@"SAPAudioTableViewCellIndentifier"];
    [self.view addSubview:self.tableView];
    [_tableView release];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        SAPLIvePlayTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SAPLIvePlayTableViewCellIndentifier"];
        cell.userInteractionEnabled = NO;
        return cell;
    }
    
   
    else if (indexPath.section == 1) {
    SAPAudioTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SAPAudioTableViewCellIndentifier"];
        cell.delegate = self;
        return cell;
    
    }
    return nil;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        return SCREEN_SIZE.height / 4;
    }else {
        return SCREEN_SIZE.height * 1.5 + SCREEN_SIZE.width / 3 + 40;
    }
}
- (void)passName:(NSString *)name withId:(NSString *)ids withDescrition:(NSString *)descrition withImgurl:(NSString *)img withBigimgurl:(NSString *)big {
    
    SAPAudioTwoViewController *twoVC = [[SAPAudioTwoViewController alloc] init];
    twoVC.string = ids;
    twoVC.name = name;
    twoVC.descrition = descrition;
    twoVC.album_imgurl = img;
    twoVC.album_bigImgurl = big;
    [self.navigationController pushViewController:twoVC animated:YES];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    if (section == 1) {
    
        return @"点播";
    }else {
        return nil;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return CGFLOAT_MIN;
    }else {
        return 30;
    }
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
  
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
